package cn.lili.modules.promotion.client;

import cn.lili.modules.constant.ServiceConstant;
import cn.lili.modules.order.order.entity.dos.OrderItem;
import cn.lili.modules.promotion.entity.dos.ReturnActivityUser;
import cn.lili.modules.promotion.fallback.ReturnActivityFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.constraints.NotBlank;
import java.util.List;

@FeignClient(path = "${server.servlet.context-path}", name = ServiceConstant.PROMOTION_SERVICE, contextId = "return-activity", fallback = ReturnActivityFallback.class)
public interface ReturnActivityClient {

    /**
     * 为用户生成用户全返卷
     *
     * @param orderItem 子订单
     * @param userId    用户ID
     */
    @PostMapping("/feign/promotion/return/activity/generate")
    Boolean generate(@RequestParam String userId, @RequestBody OrderItem orderItem);

    /**
     * 更新用户全返卷 生效全返卷
     *
     * @param userId      用户ID
     * @param orderSn    订单号
     * @param orderItemSn 子订单ID
     */
    @GetMapping("/feign/promotion/return/activity/updateStatus")
    Boolean updateStatus(@NotBlank @RequestParam String userId, @RequestParam String orderSn, @RequestParam String orderItemSn);

    /**
     * 更新用户全返卷 使用状态
     *
     * @param useStatus 使用状态
     * @param id        用户全返卷ID
     */
    @GetMapping("/feign/promotion/return/activity/updateUseStatus")
    Boolean updateUseStatus(@NotBlank @RequestParam String id, @NotBlank @RequestParam String useStatus);

    /**
     * 更新到期状态
     * @return 是否更新成功
     * */
    @GetMapping("/feign/promotion/return/activity/updateBecomeDue")
    Boolean updateBecomeDue();

    /**
     * 查询用户全返卷
     * @return 全返卷列表
     * */
    @GetMapping("/feign/promotion/return/activity/getList")
    List<ReturnActivityUser> getList(@RequestParam String userId);

    /**
     * 查询用户全返卷
     * @return 全返卷列表
     * */
    @GetMapping("/feign/promotion/return/activity/getById")
    ReturnActivityUser getById(@RequestParam String id);

    /**
     * 根据用户和订单号删除全返券
     *
     * @param orderItemSn 子订单号
     * @param userId    用户ID
     */
    @GetMapping("/feign/promotion/return/activity/deleteUserReturnActivity")
    Boolean deleteUserReturnActivity(@RequestParam String userId, @RequestParam String orderItemSn);

    /**
     * 根据用户和订单号删除全返券
     *
     * @param orderSn 子订单号
     * @param userId    用户ID
     */
    @GetMapping("/feign/promotion/return/activity/deleteUserReturnActivityByOrderSn")
    Boolean deleteUserReturnActivityByOrderSn(@RequestParam String userId, @RequestParam String orderSn);
}
